package edu.sctu.practice.class02.xuqianlan.assign.assign03.One;

import edu.sctu.practice.class02.xuqianlan.assign.assign03.One.*;
import edu.sctu.practice.class02.xuqianlan.assign.assign03.One.GeometricObject;

/**
 * Created by hj on 2015/10/22.
 */
public class Circle extends GeometricObject {
    //子类 圆
    protected double radius;

    //Default constructor默认构造
    public Circle() {
        this(1.0, "white", 1.0);
    }

    //Construct circle with specified radius 构造圆用指定的半径
    public Circle(double radius) {
        super("white", 1.0);
        this.radius = radius;
    }

    // Construct a circle with specified radius, weight, and color
    //构造一个圆包含半径、重量、颜色
    public Circle(double radius, String color, double weight) {
        super(color, weight);//继承父类的颜色和重量
        this.radius = radius;
    }

    public double getRadius() {
        return radius;
    }

    public void setRadius(double radius) {
        this.radius = radius;
    }

    // Implement the findArea method defined in GeometricObject
    //执行findArea方法几何对象被定义的
    public double findArea(){
        return radius*radius*Math.PI;
    }
    // Implement the findPerimeter method in GeometricObject
    //执行findPerimeter方法几何对象被定义的
    public double findPerimeter() {
        return 2 * radius * Math.PI;
    }

    //Override the equals()method defined in the Object class
    //覆盖equals()方法？？和==有区别
    public boolean equals(edu.sctu.practice.class02.hujie.cgs.assign03.One.Circle circle) {
        return this.radius == circle.getRadius();
    }

    //Override the toString()method defined in the Object class
    //覆盖toString()方法？？有啥用呢？
    public String toString() {
        return "[Circle] radius=" + radius;
    }
}
